local shishi = fk.CreateSkill {
  name = "ls__shishi",
  tags = { "Phase" }
}

Fk:loadTranslationTable{
  ["ls__shishi"] = "恃势",
  [":ls__shishi"] = "阶段技，你可移去中央区内所有红色牌，视为使用【落井下石】，若中央区内红色牌较多，此牌可指定手牌数不大于移去牌数的角色为目标。",
  ["#ls__shishi-prompt"] = "恃势：你可选择一名角色，视为对其使用【落井下石】",

  ["$ls__shishi1"] = "阿瞒聚众来犯，吾一人可挡万敌！",
  ["$ls__shishi2"] = "勇绝河北，吾足以一柱擎天！",
}

local DIY = require "packages/diy_utility/diy_utility"

shishi:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

shishi:addEffect("active", {
  anim_type = "offensive",
  prompt = "#ls__shishi-prompt",
  max_phase_use_time = 1,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    local card = Fk:cloneCard("lvshi__rockfall")
    local reds = #table.filter(DIY.getCenterCards(Fk:currentRoom()), function (id)
      return Fk:getCardById(id).color == Card.Red
    end)
    local blacks = #table.filter(DIY.getCenterCards(Fk:currentRoom()), function (id)
      return Fk:getCardById(id).color == Card.Black
    end)
    return #selected == 0 and (player:canUseTo(card, to_select) or
    (reds > blacks and to_select:getHandcardNum() <= reds))
  end,
  target_num = 1,
  card_num = 0,
  on_use = function(self, room, effect)
    local from = effect.from
    local to = effect.tos[1]
    local reds = table.filter(DIY.getCenterCards(room), function (id) return Fk:getCardById(id).color == Card.Red end)
    if #reds > 0 then
      DIY.removeCenterCards(from, reds)
    end
    room:useVirtualCard("lvshi__rockfall", nil, from, to, shishi.name, true)
  end,
})

return shishi